After completing this lesson, you'll be able to:
Besides constant attribute values, FME also allows you to construct values using string manipulation and arithmetic calculations. This procedure is achieved by clicking on the arrow in the Attribute Value field and selecting either Open Text Editor or Open Arithmetic Editor:
This method is advantageous because the attribute no longer needs to be a fixed value; it can be constructed from a mix of existing attributes, parameters, and constants.
The Text Editor - as you would expect - allows you to construct a text value. It includes all the usual string-handling functionality you need, such as concatenation, trimming, padding, and case-changing.
The Text Editor looks like this:
Here, the user constructs an address string by concatenating various existing attributes with some fixed characters (the commas).
Notice the menu on the left-hand side. Existing attributes are listed here, and you can add them to the string by double-clicking them. Also, notice the other menu options. Maybe the most important for text are String Functions:
These functions can be used to manipulate strings. For example, here, the user is making sure the attributes being used are trimmed when used:
This would turn
PSTLCITY: Vancouver
PSTLPROV: BC
POSTALCODE: V5V 0A1
into
ADDRESS: Vancouver, BC, V5V 0A1
After processing, FME trimmed the leading and trailing whitespace and concatenated the separate attributes with commas.
Notice the Date/Time functions in the Text Editor, which can be used to manipulate dates, times, and datetime strings, including TimeZone components.
The Arithmetic Editor is much the same as the Text Editor, except that FME evaluates whatever is entered into the dialog as an arithmetic expression and returns a numeric result:
Here, the user calculates the monthly number of visitors to a park by dividing the annual number of visitors by 12 (twelve). As with the Text Editor, existing attributes and arithmetic functions are obtained from the menu on the left-hand side.
The contents of the Arithmetic Editor must form an arithmetic expression that can be evaluated mathematically.
One other item in the menu of both Text and Arithmetic Editors is the FME Feature Functions:
These are functions that use the very heart of FME's functionality. They are the building blocks that transformers are built upon, essential functionality that can return values to the editor.
For example, the @Area() function returns the area of the current feature (assuming it is a polygon). @CoordSys() returns the coordinate system. They are the functional equivalent of the AreaCalculator and CoordinateSystemExtractor transformers.
Some functions return strings; others return numeric values. Therefore, the available functions vary depending on whether you are using the Text or Arithmetic Editor is being used. In the screenshot above, the Text Editor functions are on the left, and the Arithmetic Editor functions on the right. The Text Editor can use either text or numeric values; the Arithmetic Editor can only ever accept numeric values.
FME Feature Functions are helpful because they allow you to build processing directly into the AttributeManager instead of using a separate transformer.
Integrated Text and Arithmetic Editors provide an excellent benefit for workspace creation. They allow attribute-creating functions to be carried out directly in a single transformer.
For example, the AttributeManager Text Editor can be used as a direct replacement for the StringConcatenator and ExpressionEvaluator transformers.
The AttributeManager could also replace the StringPadder and AttributeTrimmer transformers, albeit with less user-friendliness. If FME Feature Functions are used inside the editor, this transformer could also technically replace transformers such as the AreaCalculator, LengthCalculator, DateTimeStamper, and many more.
This feature is usually a good thing. Workspaces will be more compact and well-defined when as many peripheral operations as possible are directly integrated into a single transformer. However, because an AttributeManager can carry out many operations, it is also critical to use best practices and ensure it has the proper annotation.
If an AttributeManager is not annotated correctly, it isn't possible to determine what action it carries out from looking at the Workbench canvas!